<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <textarea></textarea>
    <button onclick="add()">发布</button>
    <ul></ul>
</body>
</html>
<script>
    var text=document.querySelector('textarea')
    var ul=document.querySelector('ul')

    function add(){
        var li=document.createElement('li')
        li.innerHTML=text.value
        ul.appendChild(li)
        text.value=''
    }
    document.onkeyup=function(e){
        if(e.keyCode==13){
            add()
        }
    }
</script>